import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

class MyPlugins extends StatelessWidget{
  bool _selectValue=false;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("第三方插件演示"),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          ThirdPlugin(),
        ],
      )
      );
  }
}
class ThirdPlugin extends StatefulWidget{
  @override
    ThirdPluginState createState() {
      // TODO: implement createState
      return ThirdPluginState();
    }
}
class ThirdPluginState extends State<ThirdPlugin>{
   DateTime dataTime=DateTime.now();
   TimeOfDay dd=TimeOfDay(hour: 9,minute: 40);
  Future selectDate() async{
    DateTime date=await showDatePicker(
      context: context,
      initialDate: dataTime,
      firstDate: DateTime(2012),
      lastDate: DateTime(2022)
    );
    setState(() {
          dataTime=date;
        });
  }
  Future selectTime() async{
    final TimeOfDay time=await showTimePicker(
      context: context,
      initialTime: dd,

    );
    if(time==null)return;
    setState(() {
          dd=time;
        });
  }
  @override
    Widget build(BuildContext context) {
      // TODO: implement build
      return Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          InkWell(
            child: Row(
              children: <Widget>[
                Text(DateFormat.yMd().format(dataTime)),
                Icon(Icons.arrow_drop_down),
              ],
          ),
          onTap: (){
            selectDate();
          },
      ),
      InkWell(
            child: Row(
              children: <Widget>[
                Text(dd.format(context)),
                Icon(Icons.arrow_drop_down),
              ],
          ),
          onTap: (){
            selectTime();
          },
      )
      
        ],
      );
    }
}


